<!DOCTYPE html>
<html lang="en">
<head>
	{include file='public/header' /}
	<!-- Fancy-Buttons CSS -->
	<link href="__PUBLIC__/admin/dist/css/fancy-buttons.css" rel="stylesheet" type="text/css">

	<!-- switchery CSS -->
	<link href="__PUBLIC__/admin/vendors/bower_components/switchery/dist/switchery.min.css" rel="stylesheet" type="text/css"/>
	<!-- Custom CSS -->
	{include file='public/comn_css' /}
</head>

<body>
<!--Preloader-->
<div class="preloader-it">
	<div class="la-anim-1"></div>
</div>
<!--/Preloader-->
<div class="wrapper  theme-5-active pimary-color-blue">

	<!-- Top Menu Items -->
	{include file='public/top_menu' /}
	<!-- /Top Menu Items -->

	<!-- Left Sidebar Menu -->
	{include file='public/sidebar' /}
	<!-- /Left Sidebar Menu -->

	<!-- Main Content -->
	<div class="page-wrapper">
		<div class="container-fluid">

			<!-- Title -->
			<div class="row heading-bg">
				<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
					<h5 class="txt-dark">生成栏目页</h5>
				</div>
				<!-- Breadcrumb -->
				<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
					<ol class="breadcrumb">
						<li><a href="{:url('admin/index/index')}">系统首页</a></li>
						<li class="active"><span>生成栏目页</span></li>
					</ol>
				</div>
				<!-- /Breadcrumb -->
			</div>
			<!-- /Title -->

			<div class="row">
				<!-- Table Hover -->
				<div class="col-sm-12">
					<div class="panel panel-default card-view">
						<div class="panel-wrapper collapse in">
							<div class="panel-body">
								<div class="table-wrap">
									<div class="table-responsive">
										<table class="table table-hover table-bordered mb-0">
											<tr>
												<td>选择栏目</td>
												<td>
													<select name="category" id="category" class="form-control">
														<option value="0">更新所有栏目</option>
														{notempty name='list'}
														{foreach name='list' item='value'}
														<option value="{$value.id}" {notempty name="value.url"}disabled=""{/notempty}>
														{notempty name='value.parentid'}
														{for start="0" end="$value._level-1" step="1" name="i" }
														&nbsp;&nbsp;
														{/for}
														└
														{/notempty}
														{$value.title}
														</option>
														{/foreach}
														{/notempty}
													</select>
												</td>
											</tr>
											<tr>
												<td>是否更新子栏目</td>
												<td>
													<div class="form-group">
														<div class="col-sm-3">
															<div class="radio radio-info">
																<input type="radio" name="status" id="radio3" value="1" checked="">
																<label for="radio3">
																	更新子栏目
																</label>
															</div>

														</div>
														<div class="col-sm-3">
															<div class="radio radio-info">
																<input type="radio" name="status" id="radio4" value="0">
																<label for="radio3">
																	仅更新本栏目
																</label>
															</div>
														</div>

													</div>
												</td>
											</tr>
											<tr>
												<td colspan="2" class="text-center">
													<button class="btn btn-primary" onclick="start_update(this);">开始更新</button>
												</td>
											</tr>
										</table>
										<div class="col-sm-12" style="padding: 0;" id="box-1">
                                            <table class="table table-hover table-bordered mb-0">
                                                <tr>
                                                    <td class="text-center">
                                                        <p id="start_step" class="hide">正在生成缓存列表...</p>
                                                        <div class="progress progress-lg hide" id="end_step">
                                                            <div class="progress-bar progress-bar-danger" id="jindu" style="width: 0%;" role="progressbar">0%</div>
                                                        </div>
                                                    </td>
                                                </tr>
                                            </table>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- /Table Hover -->
			</div>

		</div>

		<!-- Footer -->
		{include file='public/footer' /}
		<!-- /Footer -->

	</div>
	<!-- /Main Content -->

</div>
<!-- /#wrapper -->

<!-- JavaScript -->

<!-- jQuery -->
<script src="__PUBLIC__/admin/vendors/bower_components/jquery/dist/jquery.min.js"></script>

<!-- Bootstrap Core JavaScript -->
<script src="__PUBLIC__/admin/vendors/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

<!-- Piety JavaScript -->
<script src="__PUBLIC__/admin/vendors/bower_components/peity/jquery.peity.min.js"></script>
<script src="__PUBLIC__/admin/dist/js/peity-data.js"></script>

<!-- Slimscroll JavaScript -->
<script src="__PUBLIC__/admin/dist/js/jquery.slimscroll.js"></script>

<!-- Owl JavaScript -->
<script src="__PUBLIC__/admin/vendors/bower_components/owl.carousel/dist/owl.carousel.min.js"></script>

<!-- Switchery JavaScript -->
<script src="__PUBLIC__/admin/vendors/bower_components/switchery/dist/switchery.min.js"></script>

<!-- Fancy Dropdown JS -->
<script src="__PUBLIC__/admin/dist/js/dropdown-bootstrap-extended.js"></script>

<!-- Init JavaScript -->
{include file='public/comn_js' /}

<script src="__PUBLIC__/admin/vendors/layer/layer.js"></script>

<script>
	function start_update(obj) {
	    var category = $('#category').val();
	    var status   = $("input[name='status']:checked").val();
        $('#start_step').removeClass('hide');
        $('#end_step').addClass('hide');
        $('#jindu').css('width', '0%');
        $('#jindu').text('0%');
        $(obj).attr('disabled', true);
		$.post("{:url('categoryUpdate')}", {
		    category:category,
			status:status
		}, function (data) {
			if (data)
			{
                $('#start_step').addClass('hide');
                $('#end_step').removeClass('hide');
                get_persent(0, obj);
			}
        })
    }
    
    function get_persent(key, obj) {
        $.post("{:url('frameHtml')}", {type:1, k:key}, function (data) {
            if (data.key+1 < data.total)
            {
                $('#jindu').css('width', data.per+'%');
                $('#jindu').text(data.per+'%');
                get_persent(data.key+1, obj)
            } else {
                $('#jindu').css('width', '100%');
                $('#jindu').text('100%');
                layer.msg('更新完成！');
                $(obj).attr('disabled', false);
            }
        })
    }
</script>
</body>

</html>
